package com.liuyz;

import java.util.Comparator;
import java.util.TreeMap;

@SuppressWarnings({"all"})
public class TreeMap_ {

    public static void main(String[] args) {
        // TreeMap treeMap = new TreeMap();

        TreeMap treeMap = new TreeMap(new Comparator() {
            @Override
            public int compare(Object o1, Object o2) {
                // 按照长度从大到小进行排序
                return ((Integer) o2).toString().length() - ((Integer) o1).toString().length();
            }
        });

        treeMap.put(999, "张三");
        treeMap.put(888, "张三");
        treeMap.put(1001, "张三");
        treeMap.put(62, "张三");
        System.out.println(treeMap);
    }
}
